// Sql.h: interface for the CLSql class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_APPSQL_H__28CC4B40_0EDC_4E46_9694_7AE4B05874DD__INCLUDED_)
#define AFX_APPSQL_H__28CC4B40_0EDC_4E46_9694_7AE4B05874DD__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "str.h"
#include "sql.h"
#include "clappsql_inc.h"
#ifndef _WIN32
#include <sys/time.h>
#endif

class CLAppSql: public CLSql  
{
public:
	CLAppSql();
	CLAppSql(LPCSTR conf_file);
	~CLAppSql();

	int init(unsigned long prog,LPCSTR host="localhost",LPCSTR protocol="udp",int count=3,int timeout=5);
	int open(int ver);
	int status(int ver,long* status,long* connect,long* err);
	void status(CLStr& result);
	int reload(int ver,LPCSTR conf_file); 
	void reload(LPCSTR conf_file,CLStr& result);

	// clsql functions
	void close();
	int  init(const CLConfig& conf);
	int  query(LPCSTR sql,CLStr& result,int with_field=0);

	int		m_count;
	int 	m_try;
private:
	struct 	timeval m_timeout;
	CLStr	m_host,m_protocol;
	unsigned long m_prog;
	CLIENT*	m_clnt;
	int		m_ver;
};

#endif // !defined(AFX_APPSQL_H__28CC4B40_0EDC_4E46_9694_7AE4B05874DD__INCLUDED_)
